"""
The editors module of GameJockey Python contains the panels that
edit project components.  Each module will map the type of the
data it edits to the appropriate editor panel in the editor_panels
variable.
"""
import wx, os, sys

# Here's a list of editor factories.
# Each entry should contain a tuple:
# (editor factory callable,factory name,factory icon)
editor_factories = []

file_openers = []

def load_all():
	"""
	Loads all the editor modules in the editors directory.
	"""
	# TODO: Iterate over all the available editors.
	
	import tile_map
	import code

def load_image(name):
	"""
	Loads an image given the image name.
	"""
	filename = os.path.join(os.path.join(
	                        os.path.dirname(sys.argv[0]), "editors"),
	                        name + ".png")
	return wx.Bitmap(filename)

class EditorFactoryInfo(object):
	"""
	Info about an editor factory.
	 - For factory, provide a callable object (i.e. a class), which can be
	   passed a reference to the current application object (EditorApp).
	   This factory can then add things to the project.
	 - For title, indicate the editor factory's title
	   (i.e. New Image, New Tile Map)
	 - For image, provide the name of an image in this directory, which
	   should be shown alongside the factory in the toolbar.
	"""
	def __init__(self,
	             title,
	             image,
	             factory,
	             large_image = None):
		self.title       = title
		self.image       = load_image(image)
		if large_image is None:
			large_image = 'new ' + image
		self.large_image = load_image(large_image)
		self.factory     = factory

def register_factory(factory):
	"Registers an editor factory class."
	editor_factories.append(factory)

def register_opener(opener):
	"Registers a file opener."
	file_openers.append(opener)
